<?php 
require_once("../../includes/_ClsCon.php");
$db = new MySQLi('localhost','root','12345','notarios');
$_obj   = new _ClsCon();        
		
	$estado 			= $_POST['estado'];	
	$numformu 			= $_REQUEST['numformu'];
	$solicitanted 		= $_REQUEST['solicitanted'];
	$rangopc1  			= $_REQUEST['rangopc1'];
	$rangopc2  			= $_REQUEST['rangopc2'];
	
	
	$db = new MySQLi('localhost','root','12345','notarios');
	
	$limite				= $_POST['limite'];

	$query2 = "SELECT id_domiciliario FROM cert_domiciliario";
	$res2=$db->query($query2);
	$total=$res2->num_rows;
	$paginas=ceil($total/4);
	
	
    $query = "CALL spLisDomiciliarios('".$rangopc1."' ,'".$rangopc2."' ,'".$solicitanted."' ,'".$numformu."' ,'".$estado."' ,".$limite.")";
	
	$res = $db->query($query);
	
if($res2->num_rows){	

while ($rowkar = $res->fetch_array())
{	



	$nomyape=strtoupper($rowkar['nombre_solic']);
	$textorefe=str_replace("?","'",$nomyape);
	$textoampers=str_replace("*","&",$textorefe);
	$textoamperss=str_replace("ñ","Ñ",$textoampers);
	$refii=strtoupper($textoamperss);

	$numcarta = $rowkar['num_certificado'];
	$numcarta2 = substr($numcarta,5,6).'-'.substr($numcarta,0,4);
	
	
	$fecha = $rowkar['fec_ingreso'];
	$fecha1 = explode ("-",$fecha);
	$fecha2 = $fecha1[2] . "/" . $fecha1[1] . "/" . $fecha1[0];


$domiciliario[]= "<table width='880' border='1' cellpadding='0' cellspacing='0' bordercolor='#333333' >
  <tr>
    <td width='63' align='center' ><span class='reskar'><a href='EdiCertDomiVie.php?id_domiciliario=".$rowkar['id_domiciliario']."'>".$numcarta2."</a></span></td>
	<td width='86' align='center' ><span class='reskar'>".$fecha2."</span></td>
	<td width='86' align='center' ><span class='reskar'>".$rowkar['num_formu']."</span></td>
    <td width='100' align='center'><span class='reskar'>".$refii."</span></td>
  </tr>
</table>";
}
}

foreach($domiciliario as $domi){
	
	echo "<article >".$domi."</article>";
	}		

echo "<table width='300' border='0' cellspacing='0'cellpadding='0'>
  <tr>
    <td width='45'>"; if ($limite>0){
	
	$limit=$limite-20;
	echo "<input type='hidden' value='".$limit."' id='_imagen' /><aside onClick=\"cargakardex(".$limit.")\"><img src='../../ante.png' width='37' height='36' border='0' title='Anterior'></aside>";
	
	}else{
		echo "<input type='hidden' value='".$limit."' id='_imagen' /><aside></aside>";
		}  echo"</td>
    		<td width='100'>";
			echo "total de pag :"." ".$paginas;
			echo"</td>
    <td width='50'>"; 
	
	if ($limite<$total-20){
	
	$limit=$limite+20;
	echo "<aside onClick=\"cargakardex(".$limit.")\"><img  src='../../sigte.png' width='37' height='36' border='0' title='Siguiente'></aside>";
	
	}else{
		echo "<aside></aside>";
		}
	
	echo"</td>
  </tr>
</table>";
?>


